Skip to content

Obtain the minimum edit distance between two strings, supplement or truncate a string to length n, remove the leading or trailing spaces from a string, truncate a string from a field, and find the position where a string starts

Use the levenshtein_distance function to obtain the minimum edit distance between two strings. Use the lpad or rpad function to supplement or truncate a string to length n. Use the rtrim function to remove the trailing spaces from a string. Use the ltrim function to remove the leading spaces from a string. Use the substr function to truncate a string from a field. Use the strpos function to find the position where a string starts and return 0 if the start position is not found. The results are displayed in a table.

SQL
|
select
  levenshtein_distance(http_method, http_type) as "Obtain the minimum edit distance between two strings",
  lpad(http_method, 4, http_type) as "Supplement or truncate a string to 4 characters",
  rtrim(host) as "Remove the trailing spaces from a string",
  ltrim(host) as "Remove the leading spaces from a string",
  substr(bucket_storage_type, 5) as "Truncate a string from the bucket_storage_type field",
  strpos(host, http_method) as "Find the position where a string starts and return 0 if the start position is not found"